using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class CareerSpeciality : EveProperty 
    {
        private int careerId;
        private string specialityName;
        private string description;
        private string shortDescription;
        private int graphicId;
        private int departmentId;

        private Career career;
        private Graphic graphic;

        private List<CareerSpecialitySkill> skills;

        public Career Career
        {
            get
            {
                if (career == null)
                    career = new Career(db, careerId);
                return career;
            }
        }
        public string Name
        {
            get { return specialityName; }
        }
        public string Description
        {
            get { return description; }
        }
        public string ShortDescription
        {
            get { return shortDescription; }
        }
        public Graphic Graphic
        {
            get
            {
                if (graphic == null)
                    graphic = new Graphic(db, graphicId);
                return graphic;
            }
        }
        public int DepartmentId
        {
            get { return departmentId; }
        }

        public List<CareerSpecialitySkill> Skills
        {
            get
            {
                if (skills == null)
                {
                    skills = new List<CareerSpecialitySkill>();
                    string query = "SELECT * FROM chrCareerSpecialitySkills WHERE specialityID=" + Id;
                    foreach (DbDataRow row in db.ExecuteQuery(query))
                        skills.Add(new CareerSpecialitySkill(row, this));
                }
                return skills;
            }
        }

        internal CareerSpeciality(DbDataRow dr)
            : base(dr.Database, EvePropertyType.CareerSpeciality, dr["specialityID"])
        {
            Fill(dr);
        }
        internal CareerSpeciality(Database db, int id)
            : base(db, EvePropertyType.CareerSpeciality, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM chrCareerSpcialities WHERE specialityID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            careerId = dr["careerID"];
            specialityName = dr["specialityName"];
            description = dr["description"];
            shortDescription = dr["shortDescription"];
            graphicId = dr["graphicID"];
            departmentId = dr["departmentID"];
        }
    }
}
